#pragma once

class CIMEBase
{
public:
	CIMEBase(void);
	virtual ~CIMEBase(void);

	virtual bool Init(HWND hWnd);

	virtual void OnInputLangChange(WPARAM wParam, LPARAM lParam);
	virtual void OnChar(WPARAM wParam, LPARAM lParam);
	virtual void OnStartComposition(WPARAM wParam, LPARAM lParam);
	virtual void OnComposition(WPARAM wParam, LPARAM lParam);
	virtual void OnEndComposition(WPARAM wParam, LPARAM lParam);
	virtual void OnNotify(WPARAM wParam, LPARAM lParam);

	LRESULT MsgProc(UINT message, WPARAM wParam, LPARAM lParam );

public:
	static const char* GetString() { return &ms_strOutput[0]; }

	static std::string ms_strOutput;

protected:
	inline HWND GetHandle() { return m_hWnd; }

	inline int ConvertString(const wchar_t* wText, int wLen, char* text, int len);
	inline int ConvertString(const char* text, int len, wchar_t* wText, int wLen);

private:
	HWND m_hWnd;
	UINT m_uiCodePage;
};
